package com.iknow.activity;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.AsyncTask.Status;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.GeoPoint;
import com.baidu.mapapi.MKAddrInfo;
import com.baidu.mapapi.MKDrivingRouteResult;
import com.baidu.mapapi.MKPoiInfo;
import com.baidu.mapapi.MKPoiResult;
import com.baidu.mapapi.MKSearch;
import com.baidu.mapapi.MKSearchListener;
import com.baidu.mapapi.MKTransitRouteResult;
import com.baidu.mapapi.MKWalkingRouteResult;
import com.iknow.IKnow;
import com.iknow.IKnowApiV4;
import com.iknow.User;
import com.iknow.data.QingBo;
import com.iknow.db.IKnowDataBase;
import com.iknow.http.HttpException;
import com.iknow.image.ProfileImageCacheManager;
import com.iknow.task.CommonTask.QingboTask;
import com.iknow.task.GenericTask;
import com.iknow.task.TaskAdapter;
import com.iknow.task.TaskListener;
import com.iknow.task.TaskParams;
import com.iknow.task.TaskResult;
import com.iknow.ui.model.QingBoAdapter;
import com.iknow.util.Loger;
import com.iknow.util.StringUtil;
import com.iknow.view.widget.MyListView;
import com.iknow.xmpp.service.Contact;
import com.iknow.xmpp.service.Friend;
import com.iknow.xmpp.service.PresenceAdapter;
import com.iknow.xmpp.service.aidl.IBeemRosterListener.Stub;
import com.iknow.xmpp.service.aidl.IKnowUser;
import com.iknow.xmpp.service.aidl.IRoster;
import com.iknow.xmpp.service.aidl.IXmppConnection;
import com.iknow.xmpp.service.aidl.IXmppFacade;
import com.iknow.xmpp.service.aidl.IXmppFacade.Stub;
import com.mobclick.android.MobclickAgent;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.util.StringUtils;

public class FriendActivity extends Activity
{
  private static final Intent SERVICE_INTENT = new Intent();
  private final int ACTION_ADD_FRIEND;
  private final int ACTION_GET_FRIEND_INFO;
  private final int ACTION_REMOVE_FRIEND;
  private AbsListView.OnScrollListener ListViewOnScrollListener;
  private View.OnClickListener MapLayoutClickListener;
  private View.OnClickListener MessageLayoutClickListener;
  private View.OnClickListener SubscribeActionButtonClickListener;
  private final String TAG = "FriendActivity";
  private ProgressDialog dialog;
  private AdapterView.OnItemClickListener listItemClickListener;
  private Button mActionButton;
  protected QingBoAdapter mAdapter;
  private TextView mAddressTextView;
  private BMapManager mBMapManager;
  private Button mBackButton;
  private boolean mBinded;
  private Contact mContact;
  private FriendActivity mContext;
  private Friend mFriend;
  private String mFriendID;
  private boolean mGetFriendOnce;
  boolean mGetLocalOnce;
  private Button mGetMoreButton;
  protected TaskListener mGetMoreListener;
  private Handler mHandler;
  private IRoster mIRoster;
  private ImageView mImageHead;
  private View mListHeaderView;
  protected MyListView mListView;
  private View mListViewFooter;
  protected LocalDataTask mLocalDataTask;
  private MKSearch mMKSearcher;
  private Button mMsgButton;
  private MySearchListener mMySearchListener;
  private TextView mNameTextView;
  protected CommonTask.QingboTask mQingboTask;
  private final IKnowRosterListener mRosterListener;
  private TextView mSexTextView;
  private TextView mSignatureTextView;
  private RelativeLayout mStatusImg;
  private ServiceConnection mSvrConn;
  private GetDataTask mTask;
  protected TaskListener mTaskListener;
  private Button mToolBarActionButton;
  private User mUser;
  private IXmppFacade mXmppFacade;
  private ProgressBar pb;
  private View.OnClickListener refreshListener;

  static
  {
    SERVICE_INTENT.setComponent(new ComponentName("com.iknow", "com.iknow.xmpp.service.IKnowXmppService"));
  }

  public FriendActivity()
  {
    this.mSvrConn = new XmppServiceConnection(this, null);
    this.mRosterListener = new IKnowRosterListener(this, null);
    this.mHandler = new Handler();
    this.mBinded = false;
    this.ACTION_ADD_FRIEND = 1;
    this.ACTION_REMOVE_FRIEND = 2;
    this.ACTION_GET_FRIEND_INFO = 3;
    this.mBMapManager = null;
    this.mMKSearcher = null;
    this.SubscribeActionButtonClickListener = new View.OnClickListener(this)
    {
      public void onClick()
      {
        if (FriendActivity.access$0(this.this$0) == null)
          FriendActivity.access$1(this.this$0);
        while (true)
        {
          while (true)
          {
            while (true)
            {
              return;
              if (((IKnow)this.this$0.getApplication()).isConnected())
                break;
              Toast.makeText(this.this$0, this.this$0.getString(2131361959), 0).show();
            }
            int i = IKnow.mIKnowDataBase.geteRosterItemSubscribeMode(FriendActivity.access$2(this.this$0));
            if ((i != 3) && (i != 1))
              break;
            FriendActivity.access$3(this.this$0, 2);
          }
          FriendActivity.access$3(this.this$0, 1);
        }
      }
    };
    this.listItemClickListener = new AdapterView.OnItemClickListener(this)
    {
      public void onItemClick(, View paramView, int paramInt, long paramLong)
      {
        QingBo localQingBo = this.this$0.mAdapter.getItem(paramInt - 1);
        if (localQingBo == null);
        while (true)
        {
          return;
          Intent localIntent = new Intent(this.this$0, PageActivity.class);
          localIntent.putExtra("item", localQingBo);
          this.this$0.startActivity(localIntent);
        }
      }
    };
    this.ListViewOnScrollListener = new AbsListView.OnScrollListener(this)
    {
      public void onScroll(, int paramInt1, int paramInt2, int paramInt3)
      {
      }

      public void onScrollStateChanged(, int paramInt)
      {
        switch (paramInt)
        {
        default:
        case 2:
        case 1:
        case 0:
        }
        while (true)
        {
          while (true)
          {
            while (true)
            {
              return;
              this.this$0.mAdapter.setScrolling(true);
            }
            this.this$0.mAdapter.setScrolling(true);
          }
          this.this$0.mAdapter.scrollIdle(paramAbsListView);
        }
      }
    };
    this.refreshListener = new View.OnClickListener(this)
    {
      public void onClick()
      {
        FriendActivity.access$4(this.this$0);
      }
    };
    this.MessageLayoutClickListener = new View.OnClickListener(this)
    {
      public void onClick()
      {
        if (FriendActivity.access$0(this.this$0) == null)
        {
          FriendActivity.access$1(this.this$0);
          return;
        }
        Intent localIntent = new Intent(this.this$0, XmppChatActivity.class);
        localIntent.putExtra("friend_jid", FriendActivity.access$2(this.this$0));
        localIntent.putExtra("contact", new Contact(FriendActivity.access$2(this.this$0)));
        if (FriendActivity.access$5(this.this$0) == null)
          localIntent.putExtra("name", "匿名");
        while (true)
        {
          while (true)
            this.this$0.startActivity(localIntent);
          localIntent.putExtra("name", FriendActivity.access$5(this.this$0).getName());
        }
      }
    };
    this.MapLayoutClickListener = new View.OnClickListener(this)
    {
      public void onClick()
      {
        if ((FriendActivity.access$5(this.this$0).getLatitude() == 0D) && (FriendActivity.access$5(this.this$0).getLongitude() == 0D))
          Toast.makeText(FriendActivity.access$6(this.this$0), "该用户没有分享过位置", 0).show();
      }
    };
    this.mGetMoreListener = new TaskAdapter(this)
    {
      public String getName()
      {
        return "getMore";
      }

      public void onPostExecute(, TaskResult paramTaskResult)
      {
        super.onPostExecute(paramGenericTask, paramTaskResult);
        FriendActivity.access$8(this.this$0).setText("更多");
        this.this$0.mAdapter.notifyDataSetChanged();
      }

      public void onProgressUpdate(, Object paramObject)
      {
        if (paramGenericTask instanceof CommonTask.QingboTask)
        {
          List localList = (List)paramObject;
          this.this$0.mAdapter.addQingboAtFoot(localList);
          FriendActivity.access$7(this.this$0, localList.size());
        }
      }
    };
    this.mTaskListener = new TaskAdapter(this)
    {
      public String getName()
      {
        return "GetDataTask";
      }

      public void onCancelled()
      {
      }

      public void onPostExecute(, TaskResult paramTaskResult)
      {
        if (paramGenericTask instanceof FriendActivity.LocalDataTask)
        {
          FriendActivity.access$9(this.this$0).setVisibility(8);
          FriendActivity.access$10(this.this$0).setVisibility(0);
          if (this.this$0.mAdapter == null);
        }
        label122: 
        do
          while (true)
          {
            do
            {
              while (true)
              {
                return;
                this.this$0.mAdapter.notifyDataSetChanged();
                this.this$0.mGetLocalOnce = true;
                FriendActivity.access$4(this.this$0);
              }
              if (!(paramGenericTask instanceof CommonTask.QingboTask))
                break label122;
            }
            while (this.this$0.mAdapter == null);
            this.this$0.mAdapter.notifyDataSetChanged();
            FriendActivity.access$9(this.this$0).setVisibility(8);
            FriendActivity.access$10(this.this$0).setVisibility(0);
          }
        while (!(paramGenericTask instanceof FriendActivity.GetDataTask));
        FriendActivity.access$9(this.this$0).setVisibility(8);
        FriendActivity.access$10(this.this$0).setVisibility(0);
        if (paramTaskResult == TaskResult.OK)
          FriendActivity.access$11(this.this$0);
        while (true)
        {
          while (true)
          {
            if ((FriendActivity.access$5(this.this$0) == null) || (FriendActivity.access$14(this.this$0) == null));
            FriendActivity.access$14(this.this$0).reverseGeocode(new GeoPoint((int)(1000000.0D * FriendActivity.access$5(this.this$0).getLatitude()), (int)(1000000.0D * FriendActivity.access$5(this.this$0).getLongitude())));
          }
          FriendActivity.access$13(this.this$0, FriendActivity.access$12(this.this$0).getMsg());
        }
      }

      public void onPreExecute()
      {
        FriendActivity.access$9(this.this$0).setVisibility(0);
        FriendActivity.access$10(this.this$0).setVisibility(8);
      }

      public void onProgressUpdate(, Object paramObject)
      {
        if (this.this$0.mAdapter == null);
        while (true)
        {
          do
            while (true)
            {
              return;
              if (!(paramGenericTask instanceof FriendActivity.LocalDataTask))
                break;
              List localList2 = (List)paramObject;
              if ((localList2 != null) && (localList2.size() > 0))
                FriendActivity.access$15(this.this$0).setVisibility(0);
              this.this$0.mAdapter.addQingboAtHead(localList2);
            }
          while (!(paramGenericTask instanceof CommonTask.QingboTask));
          List localList1 = (List)paramObject;
          if ((localList1 != null) && (localList1.size() > 0))
            FriendActivity.access$15(this.this$0).setVisibility(0);
          this.this$0.mAdapter.clearQingboList(0, localList1.size());
          this.this$0.mAdapter.addQingboAtHead(localList1);
          FriendActivity.access$7(this.this$0, localList1.size());
        }
      }
    };
  }

  // ERROR //
  private boolean addXmppRoster()
  {
    // Byte code:
    //   0: iconst_0
    //   1: istore_1
    //   2: aload_0
    //   3: getfield 268	com/iknow/activity/FriendActivity:mIRoster	Lcom/iknow/xmpp/service/aidl/IRoster;
    //   6: ifnonnull +8 -> 14
    //   9: iconst_0
    //   10: istore_3
    //   11: goto +166 -> 177
    //   14: ldc_w 331
    //   17: astore 4
    //   19: aload_0
    //   20: getfield 244	com/iknow/activity/FriendActivity:mFriend	Lcom/iknow/xmpp/service/Friend;
    //   23: ifnull +12 -> 35
    //   26: aload_0
    //   27: getfield 244	com/iknow/activity/FriendActivity:mFriend	Lcom/iknow/xmpp/service/Friend;
    //   30: invokevirtual 337	com/iknow/xmpp/service/Friend:getName	()Ljava/lang/String;
    //   33: astore 4
    //   35: getstatic 343	com/iknow/IKnow:mIKnowDataBase	Lcom/iknow/db/IKnowDataBase;
    //   38: aload_0
    //   39: getfield 258	com/iknow/activity/FriendActivity:mFriendID	Ljava/lang/String;
    //   42: invokevirtual 349	com/iknow/db/IKnowDataBase:geteRosterItemSubscribeMode	(Ljava/lang/String;)I
    //   45: iconst_2
    //   46: if_icmpne +53 -> 99
    //   49: aload_0
    //   50: aload_0
    //   51: getfield 268	com/iknow/activity/FriendActivity:mIRoster	Lcom/iknow/xmpp/service/aidl/IRoster;
    //   54: aload_0
    //   55: getfield 258	com/iknow/activity/FriendActivity:mFriendID	Ljava/lang/String;
    //   58: aload 4
    //   60: invokeinterface 355 3 0
    //   65: putfield 276	com/iknow/activity/FriendActivity:mContact	Lcom/iknow/xmpp/service/Contact;
    //   68: aload_0
    //   69: getfield 276	com/iknow/activity/FriendActivity:mContact	Lcom/iknow/xmpp/service/Contact;
    //   72: ifnonnull +84 -> 156
    //   75: ldc_w 356
    //   78: ldc_w 358
    //   81: invokestatic 363	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   84: aload_0
    //   85: getfield 316	com/iknow/activity/FriendActivity:mContext	Lcom/iknow/activity/FriendActivity;
    //   88: ldc_w 365
    //   91: aload 4
    //   93: invokestatic 371	com/mobclick/android/MobclickAgent:onEvent	(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
    //   96: goto +83 -> 179
    //   99: aload_0
    //   100: aload_0
    //   101: getfield 268	com/iknow/activity/FriendActivity:mIRoster	Lcom/iknow/xmpp/service/aidl/IRoster;
    //   104: aload_0
    //   105: getfield 258	com/iknow/activity/FriendActivity:mFriendID	Ljava/lang/String;
    //   108: aload 4
    //   110: aconst_null
    //   111: invokeinterface 375 4 0
    //   116: putfield 276	com/iknow/activity/FriendActivity:mContact	Lcom/iknow/xmpp/service/Contact;
    //   119: goto -51 -> 68
    //   122: astore_2
    //   123: ldc_w 356
    //   126: new 377	java/lang/StringBuilder
    //   129: dup
    //   130: ldc_w 379
    //   133: invokespecial 381	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   136: aload_2
    //   137: invokevirtual 384	android/os/RemoteException:getMessage	()Ljava/lang/String;
    //   140: invokevirtual 388	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   143: invokevirtual 391	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   146: invokestatic 363	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   149: aload_2
    //   150: invokevirtual 394	android/os/RemoteException:printStackTrace	()V
    //   153: goto +26 -> 179
    //   156: aload_0
    //   157: getfield 166	com/iknow/activity/FriendActivity:mHandler	Landroid/os/Handler;
    //   160: new 10	com/iknow/activity/FriendActivity$12
    //   163: dup
    //   164: aload_0
    //   165: invokespecial 395	com/iknow/activity/FriendActivity$12:<init>	(Lcom/iknow/activity/FriendActivity;)V
    //   168: invokevirtual 399	android/os/Handler:post	(Ljava/lang/Runnable;)Z
    //   171: pop
    //   172: iconst_1
    //   173: istore_1
    //   174: goto -90 -> 84
    //   177: iload_3
    //   178: ireturn
    //   179: iload_1
    //   180: istore_3
    //   181: goto -4 -> 177
    //
    // Exception table:
    //   from	to	target	type
    //   2	119	122	android/os/RemoteException
    //   156	172	122	android/os/RemoteException
  }

  private void cancelTask()
  {
    if ((this.mTask != null) && (this.mTask.getStatus() == AsyncTask.Status.RUNNING))
      this.mTask.cancel(true);
    if ((this.mQingboTask != null) && (this.mQingboTask.getStatus() == AsyncTask.Status.RUNNING))
      this.mQingboTask.cancel(true);
  }

  private boolean deleteXmppRoster()
  {
    int i = 0;
    try
    {
      if (this.mIRoster == null)
        break label92;
      if (IKnow.mIKnowDataBase.geteRosterItemSubscribeMode(this.mFriendID) == 1)
        this.mIRoster.deleteContact(this.mContact);
      else
        this.mIRoster.cancelFollow(this.mFriendID);
    }
    catch (RemoteException localRemoteException)
    {
      Loger.e("deleteXmppRoster", "deleteXmppRoster error!!--" + localRemoteException.getMessage());
      localRemoteException.printStackTrace();
      break label92:
    }
    i = 1;
    label92: return i;
  }

  private void doNeedMore()
  {
    if ((this.mQingboTask != null) && (this.mQingboTask.getStatus() == AsyncTask.Status.RUNNING));
    while (true)
    {
      return;
      this.mGetMoreButton.setText("正在载入数据...");
      this.mQingboTask = new CommonTask.QingboTask();
      this.mQingboTask.setListener(this.mGetMoreListener);
      this.mQingboTask.setAdapter(this.mAdapter);
      TaskParams localTaskParams = new TaskParams();
      localTaskParams.put("create_user", StringUtils.parseName(this.mFriendID));
      localTaskParams.put("offset", Integer.valueOf(this.mAdapter.getCount()));
      localTaskParams.put("length", Integer.valueOf(20));
      CommonTask.QingboTask localQingboTask = this.mQingboTask;
      TaskParams[] arrayOfTaskParams = new TaskParams[1];
      arrayOfTaskParams[0] = localTaskParams;
      localQingboTask.execute(arrayOfTaskParams);
    }
  }

  private void getData()
  {
    if ((this.mQingboTask != null) && (this.mQingboTask.getStatus() == AsyncTask.Status.RUNNING));
    while (true)
    {
      return;
      this.mQingboTask = new CommonTask.QingboTask();
      this.mQingboTask.setListener(this.mTaskListener);
      this.mQingboTask.setAdapter(this.mAdapter);
      TaskParams localTaskParams = new TaskParams();
      localTaskParams.put("create_user", StringUtils.parseName(this.mFriendID));
      localTaskParams.put("offset", Integer.valueOf(0));
      localTaskParams.put("length", Integer.valueOf(20));
      CommonTask.QingboTask localQingboTask = this.mQingboTask;
      TaskParams[] arrayOfTaskParams = new TaskParams[1];
      arrayOfTaskParams[0] = localTaskParams;
      localQingboTask.execute(arrayOfTaskParams);
    }
  }

  private void getDataFailure(String paramString)
  {
    if (this.dialog != null)
      this.dialog.dismiss();
    Toast.makeText(this.mContext, paramString, 0).show();
  }

  private void getDataFinished()
  {
    if (this.dialog != null)
      this.dialog.dismiss();
    if (this.mTask.getActionCode() == 1)
      Toast.makeText(this.mContext, "添加关注成功", 0).show();
    if (this.mTask.getActionCode() == 2)
      Toast.makeText(this.mContext, "取消关注成功", 0).show();
    if (this.mTask.getActionCode() == 3)
    {
      this.mGetFriendOnce = true;
      initViewData();
    }
    initButtonText();
  }

  private void getFriendData()
  {
    if (this.mGetFriendOnce);
    while (true)
    {
      while (true)
      {
        return;
        if (((IKnow)getApplication()).isConnected())
          break;
        Toast.makeText(this, getString(2131361959), 0).show();
      }
      startTask(3);
    }
  }

  private void getLocalData()
  {
    if (this.mGetLocalOnce);
    while (true)
    {
      do
        return;
      while ((this.mLocalDataTask != null) && (this.mLocalDataTask.getStatus() == AsyncTask.Status.RUNNING));
      this.mLocalDataTask = new LocalDataTask(this, null);
      this.mLocalDataTask.setListener(this.mTaskListener);
      this.mLocalDataTask.execute(new TaskParams[0]);
    }
  }

  private void initButtonText()
  {
    int i = IKnow.mIKnowDataBase.geteRosterItemSubscribeMode(this.mFriendID);
    if ((i == 3) || (i == 1))
    {
      this.mActionButton.setText("取消关注");
      this.mActionButton.setBackgroundResource(2130837532);
    }
    while (true)
    {
      return;
      this.mActionButton.setText("添加关注");
      this.mActionButton.setBackgroundResource(2130837505);
    }
  }

  private void initView()
  {
    this.mListHeaderView = getLayoutInflater().inflate(2130903058, null);
    this.mNameTextView = ((TextView)this.mListHeaderView.findViewById(2131296327));
    this.mSignatureTextView = ((TextView)this.mListHeaderView.findViewById(2131296330));
    this.mAddressTextView = ((TextView)this.mListHeaderView.findViewById(2131296332));
    this.mAddressTextView.setOnClickListener(this.MapLayoutClickListener);
    this.mSexTextView = ((TextView)this.mListHeaderView.findViewById(2131296328));
    this.mMsgButton = ((Button)findViewById(2131296322));
    this.mMsgButton.setOnClickListener(this.MessageLayoutClickListener);
    this.mBackButton = ((Button)findViewById(2131296342));
    this.mBackButton.setOnClickListener(new View.OnClickListener(this)
    {
      public void onClick()
      {
        this.this$0.finish();
      }
    });
    this.mToolBarActionButton = ((Button)findViewById(2131296344));
    this.mToolBarActionButton.setVisibility(0);
    this.mToolBarActionButton.setText("刷新");
    this.mToolBarActionButton.setOnClickListener(this.refreshListener);
    this.pb = ((ProgressBar)findViewById(2131296345));
    this.mActionButton = ((Button)this.mListHeaderView.findViewById(2131296329));
    this.mActionButton.setOnClickListener(this.SubscribeActionButtonClickListener);
    this.mStatusImg = ((RelativeLayout)this.mListHeaderView.findViewById(2131296325));
    this.mImageHead = ((ImageView)this.mListHeaderView.findViewById(2131296326));
    this.mListView.addHeaderView(this.mListHeaderView);
    this.mListView.setAdapter(this.mAdapter);
  }

  private void initViewData()
  {
    this.mNameTextView.setText(this.mFriend.getName());
    this.mSignatureTextView.setText(this.mFriend.getTags());
    if (!(StringUtil.isEmpty(this.mFriend.getImageUrl())))
    {
      IKnow.mProfileImageCacheManager.displayProfileBimap(this.mImageHead, this.mFriend.getImageUrl());
      if (this.mFriend.getGender() != null)
        break label92;
      this.mSexTextView.setText("保密");
    }
    while (true)
    {
      do
      {
        while (true)
        {
          return;
          this.mImageHead.setImageResource(2130837551);
        }
        if (this.mFriend.getGender().equalsIgnoreCase("0"))
          label92: this.mSexTextView.setText("女");
        if (this.mFriend.getGender().equalsIgnoreCase("1"))
          this.mSexTextView.setText("男");
      }
      while (!(this.mFriend.getGender().equalsIgnoreCase("2")));
      this.mSexTextView.setText("保密");
    }
  }

  private void setupListViewFooter()
  {
    this.mListViewFooter = getLayoutInflater().inflate(2130903105, null);
    this.mGetMoreButton = ((Button)this.mListViewFooter.findViewById(2131296480));
    this.mGetMoreButton.setOnClickListener(new View.OnClickListener(this)
    {
      public void onClick()
      {
        FriendActivity.access$31(this.this$0);
      }
    });
    this.mListView.addFooterView(this.mListViewFooter);
    this.mListViewFooter.setVisibility(8);
  }

  private void showNewQingboTips(int paramInt)
  {
    if (paramInt == 0)
      Toast.makeText(this, "没有新内容，先逛逛其他的吧", 0).show();
  }

  private void showProgress(String paramString)
  {
    this.dialog = ProgressDialog.show(this, "提示", paramString, true);
    this.dialog.setCancelable(true);
  }

  private void startRegisterActivity()
  {
    Intent localIntent = new Intent(this.mContext, LoginActivity.class);
    this.mContext.startActivity(localIntent);
  }

  private void startTask(int paramInt)
  {
    if ((this.mTask != null) && (this.mTask.getStatus() == AsyncTask.Status.RUNNING));
    while (true)
    {
      return;
      TaskParams localTaskParams = new TaskParams();
      localTaskParams.put("code", Integer.valueOf(paramInt));
      this.mTask = new GetDataTask(this, null);
      this.mTask.setListener(this.mTaskListener);
      GetDataTask localGetDataTask = this.mTask;
      TaskParams[] arrayOfTaskParams = new TaskParams[1];
      arrayOfTaskParams[0] = localTaskParams;
      localGetDataTask.execute(arrayOfTaskParams);
    }
  }

  private void updateActionButton()
  {
    this.mHandler.post(new Runnable(this)
    {
      public void run()
      {
        FriendActivity.access$32(this.this$0);
      }
    });
  }

  private void updatePresenceIcon()
  {
    if (IKnow.mIKnowDataBase.geteRosterItemSubscribeMode(this.mContact.getJID()) == 3)
      if (this.mContact.getStatus() == 500)
        this.mStatusImg.setBackgroundResource(2130837758);
    while (true)
    {
      while (true)
      {
        return;
        this.mStatusImg.setBackgroundResource(2130837761);
      }
      this.mStatusImg.setBackgroundResource(2130837761);
    }
  }

  public void initBaiduMap()
  {
    this.mBMapManager = new BMapManager(this);
    this.mBMapManager.init(this.mContext.getString(2131361888), null);
    this.mMKSearcher = new MKSearch();
    this.mBMapManager.start();
    this.mMySearchListener = new MySearchListener(this);
    this.mMKSearcher.init(this.mBMapManager, this.mMySearchListener);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    requestWindowFeature(1);
    setContentView(2130903057);
    this.mContext = this;
    this.mUser = IKnow.mIKnowDataBase.getUser();
    this.mListView = ((MyListView)findViewById(2131296321));
    this.mListView.setOnItemClickListener(this.listItemClickListener);
    this.mListView.setOnScrollListener(this.ListViewOnScrollListener);
    setupListViewFooter();
    this.mAdapter = new QingBoAdapter(this, getLayoutInflater());
    this.mAdapter.setHeadImageClickAble(false);
    initView();
  }

  protected void onDestroy()
  {
    this.mFriend = null;
    this.mAdapter.clearQingBoList();
    this.mAdapter = null;
    super.onDestroy();
  }

  protected void onNewIntent(Intent paramIntent)
  {
    super.onNewIntent(paramIntent);
    setIntent(paramIntent);
  }

  protected void onPause()
  {
    releaseBaiduMap();
    if (this.mBinded)
    {
      unbindService(this.mSvrConn);
      this.mBinded = false;
    }
    if (this.mIRoster != null);
    try
    {
      this.mIRoster.removeRosterListener(this.mRosterListener);
      cancelTask();
      MobclickAgent.onPause(this);
      super.onPause();
      return;
    }
    catch (RemoteException localRemoteException)
    {
      Loger.e("FriendActivity", localRemoteException.getMessage());
      localRemoteException.printStackTrace();
    }
  }

  protected void onResume()
  {
    String str2;
    IKnow localIKnow = (IKnow)getApplication();
    if ((!(this.mBinded)) && (localIKnow.isAccountConfigured()))
      this.mBinded = bindService(SERVICE_INTENT, this.mSvrConn, 1);
    initBaiduMap();
    Friend localFriend = (Friend)getIntent().getParcelableExtra("friend");
    String str1 = getIntent().getStringExtra("friendID");
    if ((localFriend != null) && (this.mFriend != null))
    {
      if (!(localFriend.getID().equals(this.mFriend.getID())))
        this.mGetFriendOnce = false;
      this.mFriend = localFriend;
      if (this.mFriend == null)
        break label281;
      this.mFriendID = this.mFriend.getID();
      if (this.mFriend == null)
        break label289;
      str2 = this.mFriend.getID();
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          do
          {
            if ((this.mUser != null) && (this.mUser.getUID().equalsIgnoreCase(StringUtils.parseName(str2))))
            {
              this.mMsgButton.setVisibility(8);
              this.mActionButton.setVisibility(8);
            }
            if (this.mFriend != null)
            {
              initViewData();
              initButtonText();
            }
            if (!(this.mGetFriendOnce))
            {
              this.mAdapter.clearQingBoList();
              this.mAdapter.notifyDataSetChanged();
              this.mGetLocalOnce = false;
              this.mListViewFooter.setVisibility(8);
            }
            getLocalData();
            MobclickAgent.onResume(this);
            MobclickAgent.setSessionContinueMillis(600000L);
            super.onResume();
            return;
          }
          while ((str1 == null) || (this.mFriendID == null) || (str1.equals(this.mFriendID)));
          this.mGetFriendOnce = false;
        }
        label281: this.mFriendID = str1;
      }
      label289: str2 = this.mFriendID;
    }
  }

  public void releaseBaiduMap()
  {
    if (this.mBMapManager == null);
    while (true)
    {
      return;
      this.mMKSearcher.init(this.mBMapManager, null);
      this.mBMapManager.destroy();
      this.mBMapManager = null;
      this.mMKSearcher = null;
    }
  }

  private class GetDataTask extends GenericTask
  {
    private int mActionCode;
    private String msg = null;

    private GetDataTask()
    {
      this.mActionCode = 0;
    }

    protected TaskResult _doInBackground()
    {
      TaskResult localTaskResult;
      try
      {
        this.mActionCode = paramArrayOfTaskParams[0].getInt("code");
        if (3 == this.mActionCode)
        {
          if (FriendActivity.access$5(this.this$0) != null);
          for (String str = FriendActivity.access$5(this.this$0).getID(); (FriendActivity.access$16(this.this$0) == null) || (FriendActivity.access$16(this.this$0).createConnection() == null) || (FriendActivity.access$16(this.this$0).createConnection().getIKnowUser() == null) || (!(FriendActivity.access$16(this.this$0).createConnection().authenticatContentUser())); str = FriendActivity.access$2(this.this$0))
          {
            this.msg = "网络超时，稍后再试";
            localTaskResult = TaskResult.FAILED;
            break label327:
          }
          Friend localFriend = FriendActivity.access$16(this.this$0).createConnection().getIKnowUser().getUserInfo(StringUtils.parseName(str));
          if (localFriend != null)
          {
            FriendActivity.access$17(this.this$0, localFriend);
            IKnow.mIKnowDataBase.deleteFriend(FriendActivity.access$5(this.this$0).getID());
            IKnow.mIKnowDataBase.addFriend(FriendActivity.access$5(this.this$0));
          }
        }
        do
        {
          do
          {
            localTaskResult = TaskResult.OK;
            break label327:
            this.msg = "网络超时，稍后再试";
            localTaskResult = TaskResult.FAILED;
            break label327:
            if (1 != this.mActionCode)
              break label255;
          }
          while (FriendActivity.access$18(this.this$0));
          this.msg = "网络超时，稍后再试";
          localTaskResult = TaskResult.FAILED;
          label255: break label327:
        }
        while ((2 != this.mActionCode) || (FriendActivity.access$19(this.this$0)));
        this.msg = "网络超时，稍后再试";
        localTaskResult = TaskResult.FAILED;
      }
      catch (HttpException localHttpException)
      {
        Loger.e("GetDataTask", localHttpException.getMessage());
        localHttpException.printStackTrace();
        localTaskResult = TaskResult.FAILED;
      }
      catch (RemoteException localRemoteException)
      {
        while (true)
        {
          Loger.e("GetDataTask", localRemoteException.getMessage());
          localRemoteException.printStackTrace();
        }
      }
      label327: return localTaskResult;
    }

    public int getActionCode()
    {
      return this.mActionCode;
    }

    public String getMsg()
    {
      return this.msg;
    }
  }

  private class IKnowRosterListener extends IBeemRosterListener.Stub
  {
    public void onEntriesAdded()
      throws RemoteException
    {
    }

    public void onEntriesDeleted()
      throws RemoteException
    {
    }

    public void onEntriesUpdated()
      throws RemoteException
    {
      FriendActivity.access$30(this.this$0);
    }

    public void onPresenceChanged()
      throws RemoteException
    {
      if (FriendActivity.access$26(this.this$0).getJID().equals(StringUtils.parseBareAddress(paramPresenceAdapter.getFrom())))
        FriendActivity.access$27(this.this$0).post(new Runnable(this, paramPresenceAdapter)
        {
          public void run()
          {
            FriendActivity.access$26(FriendActivity.IKnowRosterListener.access$1(this.this$1)).setStatus(this.val$presence.getStatus());
            FriendActivity.access$26(FriendActivity.IKnowRosterListener.access$1(this.this$1)).setMsgState(this.val$presence.getStatusText());
            FriendActivity.access$28(FriendActivity.IKnowRosterListener.access$1(this.this$1));
          }
        });
    }
  }

  private class LocalDataTask extends GenericTask
  {
    protected TaskResult _doInBackground()
    {
      List localList;
      try
      {
        localList = IKnow.mApi.getQingboListByRosterIDLocal(StringUtils.parseName(FriendActivity.access$2(this.this$0)), 0, 20);
        Object[] arrayOfObject = new Object[1];
        arrayOfObject[0] = localList;
        publishProgress(arrayOfObject);
        return TaskResult.OK;
      }
      catch (HttpException localHttpException)
      {
        Loger.e("FriendActivity", localHttpException.getMessage());
        localHttpException.printStackTrace();
      }
    }
  }

  public class MySearchListener
  implements MKSearchListener
  {
    public void onGetAddrResult(, int paramInt)
    {
      String str;
      if ((paramMKAddrInfo != null) && (FriendActivity.access$5(this.this$0) != null))
      {
        if ((paramMKAddrInfo.poiList == null) || (paramMKAddrInfo.poiList.size() <= 1))
          break label130;
        MKPoiInfo localMKPoiInfo = (MKPoiInfo)paramMKAddrInfo.poiList.get(0);
        Object[] arrayOfObject = new Object[3];
        arrayOfObject[0] = localMKPoiInfo.city;
        arrayOfObject[1] = localMKPoiInfo.name;
        arrayOfObject[2] = localMKPoiInfo.address;
        str = String.format("%s%s%s附近", arrayOfObject);
        FriendActivity.access$20(this.this$0).setText(str);
      }
      while (true)
      {
        if (StringUtil.isEmpty(str))
          str = "没有位置信息";
        FriendActivity.access$20(this.this$0).setText(str);
        FriendActivity.access$5(this.this$0).setPoision(str);
        return;
        label130: str = paramMKAddrInfo.strAddr;
      }
    }

    public void onGetDrivingRouteResult(, int paramInt)
    {
    }

    public void onGetPoiResult(, int paramInt1, int paramInt2)
    {
    }

    public void onGetTransitRouteResult(, int paramInt)
    {
    }

    public void onGetWalkingRouteResult(, int paramInt)
    {
    }
  }

  private class XmppServiceConnection
  implements ServiceConnection
  {
    public void onServiceConnected(, IBinder paramIBinder)
    {
      FriendActivity.access$21(this.this$0, IXmppFacade.Stub.asInterface(paramIBinder));
      try
      {
        FriendActivity.access$22(this.this$0, FriendActivity.access$16(this.this$0).getRoster());
        if (FriendActivity.access$23(this.this$0) != null)
        {
          FriendActivity.access$23(this.this$0).addRosterListener(FriendActivity.access$24(this.this$0));
          FriendActivity.access$25(this.this$0, FriendActivity.access$23(this.this$0).getContact(FriendActivity.access$2(this.this$0)));
          if (FriendActivity.access$26(this.this$0) != null)
            FriendActivity.access$27(this.this$0).post(new Runnable(this)
            {
              public void run()
              {
                FriendActivity.access$28(FriendActivity.XmppServiceConnection.access$1(this.this$1));
              }
            });
        }
        FriendActivity.access$29(this.this$0);
        return;
      }
      catch (RemoteException localRemoteException)
      {
        localRemoteException.printStackTrace();
      }
    }

    public void onServiceDisconnected()
    {
      FriendActivity.access$21(this.this$0, null);
    }
  }
}